package com.yaowk.sfp.system.api;

import com.yaowk.sfp.common.base.PageReq;
import com.yaowk.sfp.common.base.PageResp;
import com.yaowk.sfp.system.api.model.Role;
import com.yaowk.sfp.system.api.model.User;
import com.yaowk.sfp.system.api.model.view.PasswordModel;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("system")
@RequestMapping("/system/user")
public interface UserApi {

    @GetMapping
    PageResp<User> findAll(User user, PageReq pageReq);

    @GetMapping("/{id}")
    User findOne(@PathVariable Long id);

    @PostMapping
    User save(User user);

    @DeleteMapping("/{id}")
    void delete(@PathVariable Long id);

    @GetMapping("/{userId}/role")
    List<Role> roleList(@PathVariable Long userId);

    @PostMapping("/{userId}/role")
    void editRoles(@PathVariable Long userId, @RequestParam(required = false) List<Long> roleId);

    @GetMapping("/{userId}/permission")
    List<Long> findPermissions(Long userId);

    @PostMapping("/password")
    void editPassword(PasswordModel passwordModel);

}
